import type { spotItem } from '@/types/eat'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useCouponNumStore = defineStore(
  'couponNum',
  () => {
    /**
     * * 优惠券数量
     */
    const couponNum = ref<string[]>([])
    const isCouponNum = ref(false)
    /**
     * * 保存优惠券数量
     * @param val
     */
    const setCouponNum = (val: string[]) => {
      couponNum.value = val
    }

    /**
     * * 清理优惠券数量
     */
    const clearCouponNum = () => {
      couponNum.value = []
    }
    return {
      isCouponNum,
      couponNum,
      setCouponNum,
      clearCouponNum,
    }
  },
  {
    // 数据持久化
    persist: {
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
        getItem(key) {
          return uni.getStorageSync(key)
        },
      },
    },
  },
)
